set history=700
set hidden
set incsearch ignorecase hlsearch smartcase
set autochdir
set encoding=utf8
set noswapfile
set winwidth=80
set background=dark
set fillchars=vert:┃,diff:⎼,fold:⎼
set wildignore=*.o,*.pyc
set tags=./tags,tags;$HOME
set fileformats=unix,dos,mac
set scrolloff=10
set mouse-=a
filetype plugin on
filetype indent off
syntax enable
autocmd! bufwritepost vimrc source ~/.vim/vimrc

let g:mapleader = ","
nnoremap ; :
nnoremap : ;
nnoremap j gj
nnoremap k gk
nnoremap 0 g0
nnoremap $ g$
noremap <leader>w :wq!<cr>
noremap <leader>q :q!<cr>
noremap <leader>n :set nu!<cr>
noremap <leader>d d$<cr>
noremap <c-a> <esc>:w <cr>
noremap <silent> <Space> :silent noh<Bar>echo<CR>
noremap <leader>v :vsplit
noremap <leader>s :split<cr>
noremap <leader>ev :vsplit $MYVIMRC<cr>
noremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>a <Esc>:Ag!
"toggle and close nerdtree
nnoremap <leader>t :NERDTreeToggle<CR>
nnoremap <leader>c :NERDTreeClose<CR>
"keymap for window
noremap <c-h> :vertical res -5<cr>
noremap <c-j> :res -5<cr>
noremap <c-k> :res +5<cr>
noremap <c-l> :vertical res +5<cr>
noremap <leader>h :wincmd h<cr>
noremap <leader>j :wincmd j<cr>
noremap <leader>k :wincmd k<cr>
noremap <leader>l :wincmd l<cr>

nnoremap <silent> <F9> :TagbarToggle<CR>
nnoremap <silent> <F6> :Hammer<CR>

"set vim plugins
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"let Vundle manage Vundle
"required!
Bundle 'gmarik/Vundle.vim'
"Bundle 'gmarik/vundle'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'davidhalter/jedi-vim'
Bundle 'ervandew/supertab'
Bundle 'nvie/vim-flake8'
Bundle 'rstacruz/sparkup', {'rtp': 'vim/'}
Bundle 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}
Bundle 'majutsushi/tagbar'
Bundle 'rking/ag.vim'
Bundle 'Rykka/riv.vim' 
Bundle 'benjaminwhite/Benokai'
"Bundle 'vim-scripts/bloackboard.vim'
Bundle 'tomasr/molokai'
"Bundle 'klen/python-mode'
Bundle 'ddopson/underscore-cli'
Bundle 'godlygeek/tabular'
"Bundle 'gabrielelana/vim-markdown'
Bundle 'plasticboy/vim-markdown'
Bundle 'wikimatze/hammer.vim'
Bundle 'elzr/vim-json'
Bundle 'vim-scripts/indenthtml.vim'
Bundle 'vim-scripts/closetag.vim'
call vundle#end()
filetype plugin indent on

colorscheme molokai

let g:SuperTabDefaultCompletionType = "context"
let g:jedi#popup_select_first = 0
let g:vim_markdown_folding_disabled=1
let g:vim_markdown_initial_foldlevel=1
let g:markdown_enable_folding = 0
let g:riv_disable_folding = 1
let javascript_enable_domhtmlcss=1
let g:syntastic_check_on_open=1
let g:syntastic_enable_signs=1

"au add header for python script
"au BufNewFile *.py 0r ~/.vim/pyheader 
au BufNewFile *.py :call Pyheader()
au BufNewFile *.c :call Cheader()

function! Browser ()
    let line = getline (".")
    let line = matchstr (line, "http[^   ]*")
    exec "!firefox ".line
endfunction""
map <Leader>f :call Browser ()<CR>

"------ Filetypes ------"
" Vimscript
autocmd FileType vim setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" Shell
autocmd FileType sh setlocal expandtab shiftwidth=4 tabstop=8 softtabstop=4
" Ruby
autocmd FileType ruby setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" PHP
autocmd FileType php setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" X?HTML & XML
autocmd FileType html,xhtml,xml setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2
" CSS
autocmd FileType css setlocal expandtab shiftwidth=4 tabstop=4 softtabstop=4
" JavaScript
" autocmd BufRead,BufNewFile *.json setfiletype javascript
autocmd FileType javascript setlocal expandtab shiftwidth=2 tabstop=2 softtabstop=2

